﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Tag.aspx.cs" Inherits="FisheryPlatform.Web.Admin.Posts.Tag" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagName="Style" TagPrefix="Menu" Src="~/Modules/Menu/StyleMenu.ascx" %>
<%@ Register TagName="Left" TagPrefix="Menu" Src="~/Modules/Menu/LeftMenu.ascx" %>
<%@ Register TagName="Header" TagPrefix="Menu" Src="~/Modules/Menu/HeaderMenu.ascx" %>
<%@ Register TagName="Footer" TagPrefix="Menu" Src="~/Modules/Menu/FooterMenu.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <Menu:Style runat="server" ID="menuStyle" Title="Hi"></Menu:Style>
    <script type="text/javascript" src="../Js/Post/Term.js"></script>
    <script type="text/javascript" src="<%=FisheryPlatform.SiteConfig.SiteConfigManager.WebSite.JS%>/Pub/20110725/PagePromptBox.js"></script>
</head>
<body>
    <div class="wrapper">
        <Menu:Header runat="server" ID="menuHeader" />
        <div class="content">
            <Menu:Left runat="server" ID="menu_Left" />
            <div class="right">
                <div class="top">
                    文章管理>>文章标签</div>
                <div class="bottom">
                    <form id="form1" runat="server">
                    <div class="list_title">
                        <input type="button" value="增加新标签" onclick="showAddTagLayer()" />
                    </div>
                    <div id="div_List">
                    </div>
                    </form>
                </div>
            </div>
        </div>
        <Menu:Footer runat="server" ID="menuFooter" />
    </div>
</body>
</html>
<script id="tmpl_TagEdit" type="text/html">
<div class="edit" style="width:250px;"><input type="hidden" id="txt_TagId" value="0" />
    <dl>
        <dt style="width:50px;">名称：</dt><dd><input type="text" id="txt_Name" class="txt_border txt_input1"/></dd>
        <dt style="width:50px;">别名：</dt><dd><input type="text" id="txt_Slug" class="txt_border txt_input1"/></dd>        
        <dt style="width:50px;">描述：</dt><dd><textarea id="txt_Desc" cols="20" rows="8" class="txt_border"></textarea></dd>
        <dt style="width:50px;">&nbsp;</dt><dd><input type="button" value="保存" onclick="saveTag();" />&nbsp;
        <input type="button" value="取消" onclick="webPB.close();" /></dd>
    </dl>
</div>
</script>
<script type="text/javascript">
    function pageChanged(pageIndex) {
        jDoc("div_List").innerHTML = "Loading...";
        termManager.getTagList(function (json) {
            if (json.success) {
                jDoc("div_List").innerHTML = json.obj["html"];
            } else {
                jDoc("div_List").innerHTML = "数据加载失败";
            }
        }, pageIndex);
    }
    pageChanged(1);
    function showAddTagLayer(termId, parentId, o) {
        webPB.showDialog(jDoc("tmpl_TagEdit").innerHTML);
        if (termId != null && termId != undefined) {
            jDoc("txt_TagId").value = termId;
            jDoc("txt_Name").value = $(o.parentNode.parentNode.cells[0]).text().trim();
            jDoc("txt_Slug").value = o.parentNode.parentNode.cells[1].innerHTML.trim();
            jDoc("txt_Desc").value = o.parentNode.parentNode.cells[2].innerHTML.trim();
        }
    }
    function modifyTerm(termId, parentId, o) {
        showAddTagLayer(termId, parentId, o);
    }
    function saveTag() {
        var form = {};
        form.action = "13";
        form.tremId = jDoc("txt_TagId").value;
        form.name = jDoc("txt_Name").value;
        form.slug = jDoc("txt_Slug").value;
        form.desc = jDoc("txt_Desc").value;
        if (form.name.trim() == "") {
            alert("请输入名称");
            return;
        }
        $.post(termManager.url, form, function (jsonData) {
            if (jsonData.success) {
                alert("保存成功");
                jDoc.reload();
            } else {
                alert(jsonData.message);
            }
        }, "json");
    }
</script>
